#include "gd32f4xx.h"
#include "systick.h"

static uint32_t delay;

void systick_config(void)
{
	/* setup systick timer for 1000Hz interrupts */
	if (SysTick_Config(SystemCoreClock / 1000000U))
	{
		/* capture error */
		while(1)
		{
			
		}
	}
	/* configure the systick handler priority */
	NVIC_SetPriority(SysTick_IRQn, 0x01U);
}

void delay_ms(uint32_t count)
{
  delay = count * 10000;
  while(0U != delay)
	{
		//delay_decrement();
  }
}

void delay_us(uint32_t count)
{
	delay = count;
	while(0U != delay)
	{
		
	}
}

void delay_decrement(void)
{
	if (0U != delay)
	{
		delay--;
	}
}
